home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Source ƒ / Dragonsmith 1.0b2 / DNothing.c < prev    next >
Encoding:
Text File  |  1992-05-17  |  5.7 KB  |  119 lines

  1. /*
  2.     DNothing.c
  3.     
  4.     Template for a Dragon plug-in "subspecies."  Performs as advertised ╤ it don't do a thang!
  5.     
  6.     To make a new dragon named MyDragon ╤
  7.     
  8.         1.    Make a copy of Nothing.╣ and rename it MyDragon.╣
  9.         2.    Make a copy of Nothing.╣.rsrc and rename it MyDragon.╣.rsrc
  10.         3.    Open the MyDragon.╣ project and this file (DNothing.c)
  11.         4.    Save this file as DMyDragon.c (this will change "DNothing.c" in the project
  12.             window to "DMyDragon.c") ╤ you won't need a header file for your dragon class
  13.         5.    Change all occurrences of "DNothing" in this file to "DMyDragon"
  14.     
  15.     To write and debug your dragon ╤
  16.     
  17.         1.    Make a file with some 'alis' resources in it by dragging-and-dropping some files
  18.             onto the "'alis' Maker" dragon ╤ you'll need this to debug your dragon
  19.         2.    Read the source code ╤ it'll be much easier to understand what's going on!
  20.     =>    3.    Rewrite the DMyDragon::ProcessDroppings method so that it does what you
  21.             want it to do ╤ this is the heart of the finished application
  22.         4.    Things are set up (in Options╔) to use the precompiled file "PreDragon" ╤ so
  23.             don't trash or rename it unless you change the preprocessor directives there
  24.             ╤ or then you'll need to make your own precompiled headers file (try editing
  25.             PreDragon.c and recreating PreDragon) or #include a few files, like
  26.             <AppleEvents.h> and <Files.h>, in Dragon.c and elsewhere
  27.         5.    Choose "Run" from the "Project" menu.  When it's ready to go, set a breakpoint
  28.             at the beginning of your dragon's ProcessDroppings method, then "Go."
  29.             (There'll be an empty source window and the current function box will say
  30.             "Dragon.debug.╣".  Bring up the project window, open the DMyDragon.c file,
  31.             and choose "Debug" from the "Source" menu.)
  32.         6.    Use the StandardGetFile dialog that appears to choose the 'alis' resources file
  33.             that you made earlier.  Step through your ProcessDroppings and affiliated code,
  34.             debug, etc.
  35.         7.    To get a better look at what's happening inside the Dragon class's methods:
  36.             a.    Remove Dragon.debug.╣ from the MyDragon.╣ project file
  37.             b.    Add the files and libraries that comprise Dragon.debug.╣ (Dragon.c,
  38.                 FileUtils.c, HandleUtils.c, MacTraps, Main.c, and oops) to the project file
  39.             c.    Add "#define DEBUG" to the project prefix (choose "Options╔" under the
  40.                 "Edit" menu to get there)
  41.             Then run the project ╤ this'll let you step through the Dragon.debug.╣ code
  42.     
  43.     To build the final dragon application ╤
  44.     
  45.         1.    Remove Dragonsmith.debug.╣ (or the files and libraries that it's comprised of)
  46.             from the project file and add Dragonsmith.╣ in its (or their) place
  47.         2.    Change the project's partition size (choose Set Project Type╔ from the Project
  48.             menu) ╤ because of the way the THINK C Debugger works, the finished dragon
  49.             won't need as much memory as it did while debugging
  50.         3.    You'll probably want to make a few changes in the Nothing.╣.rsrc file ╤
  51.         
  52.                 'BNDL'    128    ResEdit v2.1 or higher is great for editing the various
  53.                                 "utility" resources ╤ 'BNDL', 'FREF', 'ICN#', etc.
  54.                 'FREF'        Specify what kinds of things can be dropped on your dragon
  55.                                 (the way I have Nothing.╣.rsrc set up, the user can drag-
  56.                                 and-drop anything ╤ files, folders, disks ╤ on it)
  57.                 'Drgn'    0    Put your copyright notice here
  58.                 'ICN#' etc.    Default icons are provided if you want to use them
  59.                 'TEXT',
  60.                 'styl'        128    These 2 hold styled text for the balloon help for your dragon's
  61.                                 icon in the Finder.  Leave the 'hfdr' resource alone if you
  62.                                 want to use these resources; otherwise it won't work╔
  63.                 'vers'        Change these to fit your version number, etc.
  64.                 'MoMa'    128    Number of times to call MoreMasters for more master pointers
  65.                                 (this will generally be very low, like 3 or 4 ╤ the method
  66.                                 Dragon::CallMoreMasters in Dragon.c is where I use this)
  67.                                 
  68.         4.    Choose "Build Application╔" from the "Project" menu, check the "Smart Link" box
  69.             in the dialog that comes up, and cross your fingers!
  70.             
  71.     NOTE:    You should set the "Stationery aware" SIZE bit for any dragon that doesn't actually
  72.             alter anything that's dropped on it ╤ we don't want the Finder to think it has to
  73.             make a copy of a stationery file before we get to see it!  This should be done within
  74.             THINK C ╤ some weirdness has been known to happen when there's a 'SIZE'
  75.             resource in the project resource file (or maybe it was just me ╔ )
  76.     
  77.     Created    24 Apr 1992    Template file with instructions
  78.     Modified    30 Apr 1992    Minor modifications in instructions
  79.             05 May 1992    More of the same
  80.             17 May 1992    Better, more detailed instructions to (hopefully) minimize confusion
  81.     
  82.     Copyright ⌐ 1992 by Paul M. Hoffman
  83.     Send feedback to paul.hoffman@um.cc.umich.edu
  84.     
  85.     This code may be freely used, altered, and distributed in any way you want as long as:
  86.         1.    It is GIVEN away rather than sold;
  87.         2.    This statement and the above copyright notice are left intact.
  88.     
  89. */
  90.                                     
  91. #include    "Dragon.h"
  92.  
  93. class DNothing: Dragon {
  94.  
  95.     public:
  96.         virtual OSErr    ProcessDroppings (FSSpec **docs, long numDocs);
  97.  
  98. };
  99.  
  100. OSErr DNothing::ProcessDroppings (FSSpec **docs, long numDocs)
  101. {
  102.     // If you want your dragon to do anything, you must override this method
  103.     // Do whatever you want here, but make sure you leave an inherited:: call
  104.     //    somewhere in this method (probably at or near the end) ╤ it'll call
  105.     //    DisposHandle (docs).  (Actually, this isn't really necessary if the
  106.     //    dragon doesn't hang around after ProcessDroppings.)
  107.     
  108.     return inherited::ProcessDroppings (docs, numDocs);
  109. }
  110.  
  111. Dragon *CreateGDragon (void)
  112. {
  113.     // (This function is declared in Dragon.h)
  114.     // If you want your dragon to do anything, you must change this function
  115.     //    so that it returns an instance of your dragon class ╤ forgetting to
  116.     //    do this is an easy way to get totally frustrated!
  117.  
  118.     return (Dragon *) new DNothing;
  119. }